package models;

import java.io.Serializable;


public class Location  implements Serializable
{
	private final Terrain terrain;
	private final boolean startLocation;
	private Resource resource;
	private Creature creature;
	
	public Location(Terrain terrain, Boolean startLocation)
	{
		this.terrain = terrain;
		this.startLocation = startLocation;
	}
	
	public Location(){
		this.terrain = new Terrain();
		this.startLocation = false;
	}
	
	/**
	 * Returns the Terrain details for this location.
	 * @return
	 */
	public Terrain getTerrain() 
	{
		return terrain;
	}
	
	/**
	 * Returns the resource at this location, null if none are here.
	 * @return
	 */
	public Resource getResource() 
	{
		return resource;
	}
	
	/**
	 * Returns the creature currently positioned at this location.
	 * @return
	 */
	public Creature getCreature() 
	{
		return creature;
	}
	
	/**
	 * Sets the Resource at this location.
	 * @return
	 */
	public void setResource(Resource resource) 
	{
		this.resource = resource;
	}
	
	/**
	 * Sets the creature at this location.
	 * @return
	 */
	public void setCreature(Creature creature) 
	{
		this.creature = creature;
	}
	
	/**
	 * Returns true iff this location can be a start location.
	 * @return
	 */
	public boolean isStartLocation()
	{
		return startLocation;
	}
	
	@Override
	public boolean equals(Object obj){
		boolean toReturn = true;
		
		if(obj.getClass().equals(this.getClass())){
			Location other = (Location) obj;
			
			if(!this.getTerrain().equals(other.getTerrain())){
				toReturn = false;
			}
			
			if(this.startLocation != other.startLocation){
				toReturn = false;
			}
			
		}else{
			toReturn = false;
		}
		
		return toReturn;
	}
}
